home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The Original Shareware 1.1
/
The Original Shareware (WeMake CDs)(Volume 1.1)(CDs, Inc)(1993).iso
/
19
/
madtrb11.zip
/
INKEY.INC
< prev
next >
Wrap
Text File
|
1985-07-13
|
2KB
|
46 lines
{INKEY.INC}
FUNCTION InKey(VAR special : BOOLEAN; VAR KeyChar : CHAR) : BOOLEAN;
(*
An emulation of the $INKEY function provided in BASIC. InKey returns
TRUE if a key has been pressed. If the parameter Special is also TRUE,
then the character is one of the 2-code keys (like F1-F10), and the
parameter returned in KeyChar is the code for the second key.
If you want "type-ahead" buffering of keystrokes, you must turn off
the compiler "C" directive {$C-}. If not, DOS will discard keystrokes
which haven't yet been read in.
Source: "INKEY: A Multiple Keypress Function", TUG Lines Volume I Issue 4
Author: Orville Jenkins/Panther Associates/Dallas-Ft. Worth, Texas/
Application: MS-DOS, PC-DOS
*)
var
dosrec : record ax,bx,cx,dx,bp,si,di,ds,es,flags : integer; end;
begin
if keypressed { Does DOS say char is ready? }
then { A key was pressed }
begin { inkey processing }
dosrec.ax := $0800; { Tell DOS console input without echo }
msdos(dosrec); { Call DOS }
keychar := chr(lo(dosrec.ax)); { Pull char from AL }
inkey := true; { Tell caller yes, it's a keystroke }
if ord(keychar) = 0 { Is it a 2-code key? }
then { It was }
begin
special := true; { Let caller know it's a 2-code key }
dosrec.ax := $0800; { Get the other character }
msdos(dosrec);
keychar := chr(lo(dosrec.ax));
end
else special := false; { Wasn't a 2-code key }
end
else { No key was pressed }
begin
inkey := false; { Tell caller there was no key pressed }
special := false; { and reset special key flag }
end;
end; {InKey}